package com.backstage.controller;

import com.backstage.entity.User;
import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @Project authority
 * @Package com.backstage.controller
 * @Data 2017/7/13下午 2:48.
 * @Aurhor 阮雪峰
 */
@Controller
public class BaseController {

    protected User getLoginUser(){
        return (User) SecurityUtils.getSubject().getSession().getAttribute("loginUser");
    }

    @RequestMapping(value = "{url}.html", method = RequestMethod.GET)
    public String page(@PathVariable("url") String url){
        return url;
    }

    @RequestMapping(value = "/{model}/{url}.html", method = RequestMethod.GET)
    public String page( @PathVariable("model") String model, @PathVariable("url") String url){
        return model+"/"+url;
    }
}
